package com;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import javax.servlet.http.HttpServlet;

public class LecteurFichier {

	public static String readFile(HttpServlet servlet, String nom) {
		StringBuilder builder = new StringBuilder();

		//Log.d("FILE",file.getAbsolutePath());
		nom = "/WEB-INF/"+nom;

		BufferedReader reader = null;
		try {
			reader = new BufferedReader(new InputStreamReader(servlet.getServletContext().getResourceAsStream(nom)));

			String line;
			while ((line = reader.readLine()) != null) {
				builder.append(line);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (reader != null) {
				try {
					reader.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}

		return builder.toString();
	} 

}
